package me.mingshan.algorithm.linkedlist;

/**
 * 单向链表环路检测
 *
 * https://leetcode.cn/problems/linked-list-cycle/
 *
 * @author hanjuntao
 * @date 2025/7/31 0031
 */
public class LinkedListCycle {


    static class ListNode {
        int val;
        Revert.ListNode next;
        ListNode(int x) { val = x; }

        static void print(Revert.ListNode head) {
            StringBuilder sb = new StringBuilder("[");
            for (Revert.ListNode current = head; current != null; current = current.next) {
                sb.append(current.val + ", ");
            }

            int len = sb.length();
            System.out.println(sb.delete(len - 2, len).append("]").toString());
        }
    }
}
